package com.zbar.lib;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Toast;

public class TestFileDecodeActivity extends Activity{

	private TextView mTvScan;
	private TextView mTvTips;
	
	private static final String RootPath= Environment.getExternalStorageDirectory().getPath();
	private String filePath=RootPath+File.separator+"1469000002.png";
	private File tempFile;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_test_file);
		initData();
		initViews();
	}

	private void initData() {
		tempFile=new File(filePath);
	}

	private void initViews() {
		mTvScan=(TextView) findViewById(R.id.tv_scan_restart);
		mTvTips=(TextView) findViewById(R.id.tv_scan_tips);
		mTvScan.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
//				new dec
			}
		});
	}
	
	private void showMsg(String msg){
		Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
	}
	
	//获得指定文件的byte数组 
    public static byte[] getBytes(String filePath){  
        byte[] buffer = null;  
        try {  
            File file = new File(filePath);  
            FileInputStream fis = new FileInputStream(file);  
            ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);  
            byte[] b = new byte[1000];  
            int n;  
            while ((n = fis.read(b)) != -1) {  
                bos.write(b, 0, n);  
            }  
            fis.close();  
            bos.close();  
            buffer = bos.toByteArray();  
        } catch (FileNotFoundException e) {  
            e.printStackTrace();  
        } catch (IOException e) {  
            e.printStackTrace();  
        }  
        return buffer;  
    }  
	
}
